﻿package com.wandian.util
{
	import com.wandian.data.GameData;
	
	import flash.display.DisplayObjectContainer;
	import flash.utils.Dictionary;
   
    public class CLZLoadingData extends Object
    {
        private static var DICT:Dictionary = new Dictionary();

        public function CLZLoadingData()
        {
            return;
        }

        public static function show(parentMc:DisplayObjectContainer, sx:int = 0, sy:int = 0) : void
        {
            hide(parentMc);
            var loadingMc:* = GameData.getMovieClip("LoadingData");
            parentMc.addChild(loadingMc);
            if (sx == 0)
            {
            }
            if (sy == 0)
            {
                loadingMc.x = (parentMc.width - loadingMc.width) * 0.5;
                loadingMc.y = (parentMc.height - loadingMc.height) * 0.5;
            }
            else
            {
                loadingMc.x = (sx - loadingMc.width) * 0.5;
                loadingMc.y = (sy - loadingMc.height) * 0.5;
            }
            DICT[parentMc.name] = loadingMc;
            return;
        }

        public static function hide(parentMc:DisplayObjectContainer) : void
        {
            var name:* = parentMc.name;
            if (DICT[name]==null)
            {
				trace("根据名字找动画失败");
				return;
            }
            if (parentMc.contains(DICT[name]))
            {
                parentMc.removeChild(DICT[name]);
                delete DICT[name];
                DICT[name] = null;
            }
            return;
        }

    }
}
